package com.dream.dao.base;

/**
 * 
 * @author Evan
 * @date 2013-8-25
 * 
 */
import java.util.List;

import org.springframework.stereotype.Repository;

import com.dream.model.app.AppOrg;
import com.dream.utils.hibernate.DetachedCriteriaBuilder;
import com.dream.utils.hibernate.DreamBaseDAO;

@Repository
public class AppOrgDAO extends DreamBaseDAO<AppOrg> {
	
	public AppOrg getRoot(){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppOrg.class);
		builder.addEq("deleted", false).addEq("level", 0);
		return this.selectTopOne(builder);
	}
	
	public List<AppOrg> getChildren(Long parentId){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppOrg.class);
		builder.addEq("deleted", false).addEq("parentId", parentId);
		return this.select(builder);
	}

}
